import { Database, OpenHelper } from "@ohos/dataorm";

export class PlayCarOpenHelper extends OpenHelper{
  /**
   *
   * @param context 上下文
   * @param name 数据库名称 xxx.db
   * @param customDir 自定义bd存储位置
   */
  constructor(context:any,name:string,customDir?:string) {
    super(context,name,customDir)
  }
  /**
   * 创建数据库
   * @param db
   * @returns
   */
  public async onCreateDatabase(db: Database): Promise<void> {
    super.onCreateDatabase(db)
    console.log("ClubOpenHelper onCreateDatabase创建数据库   ？？？？？");
  }
  /**
   * 数据库升级
   * @param db
   * @param oldVersion
   * @param newVersion
   * @returns
   */
  async  onUpgradeDatabase(db: Database, oldVersion: number, newVersion: number): Promise<void> {
    // console.log("ExampleOpenHelper onUpgradeDatabase oldVersion:" + oldVersion + ",newVersion:" + newVersion);
    // db.execSQL('ALTER TABLE NOTE ADD COLUMN PLACE INTEGER');
    // db.execSQL('ALTER TABLE NOTE RENAME COLUMN MONEYS TO COST');
  }
  /**
   * 数据库降级
   * @param db
   * @param oldVersion
   * @param newVersion
   * @returns
   */
  async  onDowngradeDatabase(db: Database, oldVersion: number, newVersion: number): Promise<void> {
    // console.log("ExampleOpenHelper onDowngradeDatabase oldVersion:" + oldVersion + ",newVersion:" + newVersion);
    // db.execSQL('ALTER TABLE NOTE DROP COLUMN TYPE');
    // db.execSQL('ALTER TABLE NOTE DROP COLUMN COST');
  }
}